from django.contrib.auth.models import User
from django.db import models


# Create your models here.
class Department(models.Model):
    """部门"""

    objects: models.QuerySet

    name = models.CharField("部门名称", max_length=32)
    intro = models.CharField("部门简介", max_length=256, default="")
    # 部门领导
    leader = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, default=None)


class Position(models.Model):
    """职位"""

    objects: models.QuerySet

    name = models.CharField("职位名称", max_length=32)
    is_leader = models.BooleanField("是否负责人", default=False)


class Role(models.Model):
    """角色"""

    objects: models.QuerySet
    # xx在xxx部门担任xxxx职位
    user = models.ForeignKey(
        User, on_delete=models.CASCADE
    )  # xx都离职了那这条记录也没必要存在了
    department = models.ForeignKey(
        Department, on_delete=models.CASCADE
    )  # xxx部门都解散了那这条记录也没必要存在了
    position = models.ForeignKey(
        Position, on_delete=models.CASCADE
    )  # xxxx职位都撤离了那这条记录也没必要存在了
